//
//  UIBarButtonItem+Extension.swift
//  MyMicroBlog
//
//  Created by stevenSu on 15/8/4.
//  Copyright © 2015年 stevenSu. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience init(target: AnyObject?, imageName: String, actionName: String?) {
        let btn = UIButton()
        btn.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        if let action = actionName {
            btn.addTarget(target, action: Selector(action), forControlEvents: UIControlEvents.TouchUpInside)
        }
        
        self.init(customView: btn)
    }
}